void main() {
  var str = 'tikeyc';
  String str1 = 'flutter';
  print('hello $str $str1');

  var str2 = '''
    $str $str1 dart
    多行字符串
    $str $str1
  ''';
  print(str2);

  bool a = true;
  a = false;
  print(a);

  var list1 = ['1', true, 18];

  list1.add(1);

  // var list2 = <bool>[true, false];
  // var list2 = <int>[1, 2];
  var list2 = <String>['1', '2', '3'];

  list2.addAll(['4', '5']);

  print(list2);

  print('修改数组长度');

  var list3 = [1, 2, 3];

  print(list3.length); // 3

  list3.length = 0;
  // list3.clear();

  print(list3); // 空[]

  print(5 ~/ 2); // 取整

  // var b = '1';
  var b;
  b ??= '"??="表示如果b为空的话把这段字符串赋值给b';
  print(b);

  var set1 = new Set();
  set1.add('1');
  set1.add('value');
  print(set1);
  print(set1.toList());

  var set2 = new Set();
  const listSet1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5];
  set2.addAll(listSet1); // 去重
  print(set2); // {1, 2, 3, 4, 5, 6}

  print('Map Map Map');
  var map1 = {
    'key1': 1,
    'key2': 2,
    'key3': 3,
  };
  var map2 = {
    'key1': 11,
    'key2': 22,
  };
  print(map1);
  map1.addAll(map2); // map1、map2合并
  print(map1);

  print('函数');
  void printUserInfor1(String name, int age) {
    print('name:$name--age:$age');
  }

  printUserInfor1('dart1', 10);

  void printUserInfor2(String name, [int? age = 1, String? sex]) {
    print('name:$name--age:$age--sex:$sex');
  }

  printUserInfor2('dart2', null, 'Man');

  void printUserInfor3(String name, {int? age, String sex = 'man'}) {
    print('name:$name--age:$age--sex:$sex');
  }

  printUserInfor3('dart3', age: 20, sex: 'Man');

  // required关键字: 必须传入的参数
  void printUserInfor4(String name, {required int? age, String sex = 'man'}) {
    print('name:$name--age:$age--sex:$sex');
  }

  printUserInfor4('dart3', sex: 'Man', age: 10);
}
